package cn.tedu.luban.worker.main.controller;

import cn.tedu.luban.worker.main.converter.WorkerConverter;
import cn.tedu.luban.worker.main.service.WorkerFrontService;
import cn.tedu.luban.worker.protocol.VO.FrontWorkerDetailVO;
import cn.tedu.luban.worker.protocol.bo.FrontWorkerBO;
import cn.tedu.luban.worker.protocol.param.WorkerRegistParam;
import com.tedu.inn.protocol.exception.BusinessException;
import com.tedu.inn.protocol.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/worker")
@Api(
    value = "师傅服务前台APP接口",
    tags = "师傅服务前台APP接口"
)
public class WorkerFrontController {
    @Autowired
    private WorkerFrontService workerFrontService;
    @Autowired
    private WorkerConverter workerConverter;
    @PostMapping("/create")
    @ApiOperation("师傅入住")
    public Result<Long> registWorker(@RequestBody WorkerRegistParam workerRegistParam) throws BusinessException{
        Long workerId=workerFrontService.createWorker(workerRegistParam);
        return new Result<>(workerId);
    }
    @GetMapping("/detail")
    @ApiOperation("师傅详情")
    public Result<FrontWorkerDetailVO> detailWorker() throws BusinessException{
        FrontWorkerBO frontWorkerBO =workerFrontService.detailWorker();
        return new Result<>(workerConverter.bo2vo(frontWorkerBO));
    }
}
